// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

export default class SodaUserData {
    public guan: number = 0;                //关卡数
    public integral: number = 0;            //当前游戏积分
    public passCount: number = 0;           //通关次数
    public bindPhone: number = -1;          //绑定的手机号码
    public sodaIntegral: number = 0;        //汽水易购总积分
    public lastChangeTime: number = -1;     //上次获取当前游戏积分时间
    public lastExchangeTime: number = -1;   //上次兑换为汽水积分时间
    public historyAllIntegral: number = 0;  //历史总积分

    constructor(options: { guan: number, integral: number, passCount: number, bindPhone: number, lastChangeTime: number, lastExchangeTime: number, historyAllIntegral: number, sodaIntegral: number }) {
        this.guan = options.guan;
        this.integral = options.integral;
        this.passCount = options.passCount;
        this.bindPhone = options.bindPhone;
        this.sodaIntegral = options.sodaIntegral;
        this.lastChangeTime = options.lastChangeTime;
        this.lastExchangeTime = options.lastExchangeTime;
        this.historyAllIntegral = options.historyAllIntegral;
    }

    public updateData(options: { guan?: number, integral?: number, passCount?: number, bindPhone?: number, lastChangeTime?: number, lastExchangeTime?: number, historyAllIntegral?: number, sodaIntegral: number }) {
        options!.guan !== undefined && options.guan !== null && (this.guan = options.guan);
        options!.integral !== undefined && options.integral !== null && (this.integral = options.integral);
        options!.passCount !== undefined && options.passCount !== null && (this.passCount = options.passCount);
        options!.bindPhone !== undefined && options.bindPhone !== null && (this.bindPhone = options.bindPhone);
        options!.sodaIntegral !== undefined && options.sodaIntegral !== null && (this.sodaIntegral = options.sodaIntegral);
        options!.lastChangeTime !== undefined && options.lastChangeTime !== null && (this.lastChangeTime = options.lastChangeTime);
        options!.lastExchangeTime !== undefined && options.lastExchangeTime !== null && (this.lastExchangeTime = options.lastExchangeTime);
        options!.historyAllIntegral !== undefined && options.historyAllIntegral !== null && (this.historyAllIntegral = options.historyAllIntegral);
    }
}
